﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace CNDM
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindListCatNews();
        }

        private void BindListCatNews()
        {
            DataTable dt = new DataTable();
            dt = BO.Category.CategoryData.Get_Category(0);
            if (dt != null && dt.Rows.Count > 0)
            {
                string cat_urlFormat = "<a href='{0}' title='{1}'>{1}</a>";
                string cat_url = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    CNDM.UserControls.List.ucListHome ucListHome = (CNDM.UserControls.List.ucListHome)(LoadControl("/UserControls/List/ucListHome.ascx"));
                    cat_url = String.Format(cat_urlFormat, dt.Rows[i]["Cat_Url"].ToString(), dt.Rows[i]["Cat_Name"].ToString());
                    plateHolder.Controls.Add(ucListHome);
                    ucListHome.CatName = cat_url;
                    ucListHome.Cat_ID = Convert.ToInt32(dt.Rows[i]["Cat_ID"]);
                    ucListHome.Top = 3;
                    ucListHome.BindData();
                }
            }
        }
    }
}